﻿
<div class="main">
    <table border=0 cellpadding=0 cellspacing=0 class="tb-head form-inline form-group-sm">
        <tr>
            <td align="right">
                <select class="form-control ui-queryString ui-setName" style="width:120px;">
                    <option value="remark">站点名称</option>
                    <option value="domain">绑定域名</option>
                    <option value="directory">站点目录</option>
                </select>
                <input type="text" placeholder="搜索关键词" class="form-control ui-keyword ui-queryString">
                <button type="button" class="btn btn-default btn-sm ui-queryString-search">搜索</button>

            </td>
        </tr>
    </table>
    <table border=0 cellpadding=0 cellspacing=0 class="table table-bordered" id="tb_list">
        <thead>
            <tr>
                <td align="center" width="60px">选择</td>
                <td align="center">站点名称</td>
                <td align="center">目录</td>
                <td align="center">绑定域名</td>
            </tr>
        </thead>
        <tr class="item list-template-item" id="tr_{id}" username="{name}">
            <td align="center"><input type="checkbox" id="id" name="id" value="{id}" class="ck"></td>
            <td align="center">{Remark}</td>
            <td align="center">{directory}</td>
            <td align="center">{domain}</td>
        </tr>
    </table>


    <div class="submit-footerbar">
        <label class="control-label"></label>
        <div class="controls">
            <button type="button" class="btn btn-primary" onclick="SetSite()">却换选中站点</button>
            <button type="button" class="btn btn-default ui-closeDialog">关闭</button>
        </div>
    </div>
</div>
<script type="text/javascript">

    function LoadInit()
    {
        var $idObj = $("input[name='id']");
        var currentSiteId = "@ViewBag.CurrentSiteId";
        $idObj.SetChecked(currentSiteId);
    }
    function LoadData() {
        var ajaxUrl = "@Url.ActionUrl("PageListData")?_byuser=1&_isload=1"
        $("#tb_list").ListBind({ url: ajaxUrl, callBack: "LoadInit" });
    }
    LoadData();


    $(document).on("click", "input[name='id']", function () {

        var $idObj = $("input[name='id']");
        $idObj.prop("checked", false);
        $(this).prop("checked", true);
    });

    function SetSite()
    {
        var $idObj = $("input[name='id']");
        var id = $idObj.GetChecked();
        if(id=="")
        {
            Msg("请选择要切换的站点！");
            return;
        }
        Ajax({ type: "post", dataType: "text",async: false, url: "@Url.ActionUrl("SetCurrentSite")", data: {id:id } });
        top.location.href = top.location.href;
        CloseDialog();
    }
</script>
